home *** CD-ROM | disk | FTP | other *** search
/ Graphics & Sound Program…ng Techniques for the Mac / Graphics and Sound Programming Techniques for the Mac.iso / M&T Graphics & Sound Examples / Symantec Versions / C04 Speech / P01 Quick Speech / QuickSpeech.c next >
Encoding:
C/C++ Source or Header  |  1995-08-31  |  1.8 KB  |  85 lines  |  [TEXT/KAHL]

  1. //____________________________________________________________
  2. //    QuickSpeech.c
  3. //
  4. //    Copyright © Dan Parks Sydow, 1995
  5. //    From the book:
  6. //    "Graphics and Sound Programming Techniques for the Mac",
  7. //    M&T Books, 1995
  8.  
  9.  
  10. //____________________________________________________________
  11.  
  12. #include <Speech.h>
  13.  
  14.  
  15. //____________________________________________________________
  16.  
  17. void     InitializeToolbox( void );
  18. Boolean  IsSpeechAvailable( void );
  19.  
  20.  
  21. //____________________________________________________________
  22.  
  23. void  main( void )
  24.    OSErr    theError;
  25.    Boolean  speechPresent;
  26.  
  27.    InitializeToolbox();
  28.  
  29.    speechPresent = IsSpeechAvailable();
  30.    if ( speechPresent == false )
  31.       ExitToShell();
  32.  
  33.    theError = SpeakString( "\pTesting 1 2 3 Testing 1 2 3" );
  34.    if ( theError != noErr )
  35.       ExitToShell();
  36.  
  37.    // ** if you comment out the following two lines and recompile, **
  38.    // ** you might not hear speech when the program runs. Read a   **
  39.    // ** few more pages into Chapter 4 to see why the program is   **
  40.    // ** ending before speech completes!                           **
  41.    
  42.    while ( SpeechBusy() == true )
  43.       ;
  44.  
  45. }
  46.  
  47.  
  48. //____________________________________________________________
  49.  
  50. Boolean  IsSpeechAvailable( void )
  51. {
  52.    OSErr    theError;
  53.    long     theResult;
  54.    Boolean  speechAvail;
  55.    
  56.    theError = Gestalt( gestaltSpeechAttr, &theResult );
  57.    if ( theError != noErr )
  58.       ExitToShell();
  59.       
  60.    speechAvail = theResult & ( 1 << gestaltSpeechMgrPresent );  
  61.    if ( speechAvail > 0 )
  62.       return ( true );
  63.    else
  64.       return ( false );
  65. }
  66.  
  67.  
  68. //____________________________________________________________
  69.  
  70. void  InitializeToolbox( void )
  71. {
  72.    InitGraf( &qd.thePort );
  73.    InitFonts();
  74.    InitWindows();
  75.    InitMenus();
  76.    TEInit();
  77.    InitDialogs( 0L );
  78.    FlushEvents( everyEvent, 0 );
  79.    InitCursor();
  80. }
  81.  
  82.  
  83.  
  84.